import { createRouter, createWebHistory } from "vue-router";
import { qiankunWindow } from "vite-plugin-qiankun/dist/helper";
import HomeView from "../views/HomeView.vue";

export const getNewRouter = (props: any) => {
  const router = createRouter({
    history: createWebHistory(
      qiankunWindow.__POWERED_BY_QIANKUN__
        ? props.activeRule
        : import.meta.env.BASE_URL
    ), // activeRule 是  /qkpage
    routes: [
      {
        path: "/home",
        name: "home",
        component: HomeView,
        meta: {
          keepAlive: true,
        },
      },
      {
        path: "/about",
        name: "about",
        // route level code-splitting
        // this generates a separate chunk (About.[hash].js) for this route
        // which is lazy-loaded when the route is visited.
        component: () => import("../views/AboutView.vue"),
      },
    ],
  });

  return router;
};
